package scala.mytrait

class Person {

}

object typeInstanceTest {

  def main(args: Array[String]): Unit = {
    val person = new Person

    //    (1) 判断对象是否为某个类型的实例
    val bool: Boolean = person.isInstanceOf[Person]
    if (bool) {
      //类型转换
    }

    // (2) 将对象转换为某个类型的实例
    val p1:Person = person.asInstanceOf[Person]
    println(p1)

    val p2:Class[Person] = classOf[Person]
    println(p2)
  }
}
